package com.java.mybatis.service.impl;

import com.java.mybatis.dao.OutboundDao;
import com.java.mybatis.entity.Outbound;
import com.java.mybatis.service.OutboundService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (Outbound)表服务实现类
 *
 * @author makejava
 * @since 2021-01-15 17:10:28
 */
@Service("outboundService")
public class OutboundServiceImpl implements OutboundService {
    @Resource
    private OutboundDao outboundDao;

    /**
     * 通过ID查询单条数据
     *
     * @param outboundId 主键
     * @return 实例对象
     */
    @Override
    public Outbound queryById(Integer outboundId) {
        return this.outboundDao.queryById(outboundId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Outbound> queryAllByLimit(int offset, int limit) {
        return this.outboundDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param outbound 实例对象
     * @return 实例对象
     */
    @Override
    public Outbound insert(Outbound outbound) {
        this.outboundDao.insert(outbound);
        return outbound;
    }

    /**
     * 修改数据
     *
     * @param outbound 实例对象
     * @return 实例对象
     */
    @Override
    public Outbound update(Outbound outbound) {
        this.outboundDao.update(outbound);
        return this.queryById(outbound.getOutboundId());
    }

    /**
     * 通过主键删除数据
     *
     * @param outboundId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer outboundId) {
        return this.outboundDao.deleteById(outboundId) > 0;
    }

    /**
     * 添加出库批号
     * @param outbound
     * @return
     */
    @Override
    public int addOutboundBatch(Outbound outbound){
        return outboundDao.addOutboundBatch(outbound);
    }

    /**
     * 根据批号查询货物总数量
     * @param outboundNumber
     * @return
     */
    @Override
    public int queryOutboundNumberSum(String outboundNumber){
        return outboundDao.queryOutboundNumberSum(outboundNumber);
    }

    /**
     * 根据批号查询id
     * @param outboundNumber
     * @return
     */
    @Override
    public int queryOutboundIdByOutboundNumber(String outboundNumber){
        return outboundDao.queryOutboundIdByOutboundNumber(outboundNumber);
    }

    /**
     * 分页查询订单批号
     * @param state
     * @param page
     * @param pageSize
     * @return
     */
    @Override
    public List<Outbound> queryOutboundLimit(Integer state,Integer page,Integer pageSize){
        return outboundDao.queryOutboundLimit(state, page, pageSize);
    }

    /**
     * 根据状态查询总条数
     * @param state
     * @return
     */
    @Override
    public int queryCount(Integer state){
        return outboundDao.queryCount(state);
    }

    /**
     * 修改状态  出库复核
     * @param outboundId   出库复核id
     * @return
     */
    @Override
    public int updateOutboundState(Integer outboundId){
        return outboundDao.updateOutboundState(outboundId);
    }

    /**
     * 模糊查询
     * @param map
     * @return
     */
    @Override
    public List<Outbound> queryStateLikeOutboundNumber(Map<String,Object> map){
        return outboundDao.queryStateLikeOutboundNumber(map);
    }

    /**
     * 模糊查询总条数
     * @param str
     * @return
     */
    @Override
    public int queryStateLikeCount(String str){
        return outboundDao.queryStateLikeCount(str);
    }
}